home *** CD-ROM | disk | FTP | other *** search
- #include "config.h"
-
- #include <Types.h>
- #include <Resources.h>
- #include <Packages.h>
- #include <sys/types.h>
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- #include "lint.h"
- #include "interpret.h"
- #include "exec.h"
- #include "object.h"
- #include "comm.h"
- #include "rc.h"
- #include "mac.h"
-
- #define CONFIG_SIZE 40
-
- /*
- * Do not change the values here; if you want to change something,
- * do it in the startup script.
- */
-
- struct config configs[CONFIG_SIZE];
-
- static void set_def_configs()
- {
- configs[0].cf_name = "Mud host name";
- configs[0].cf_type = CF_STR;
- configs[0].u.cf_int = "MacMud";
-
- configs[1].cf_name = "Master object file";
- configs[1].cf_type = CF_STR;
- configs[1].u.cf_str = "/obj/master";
-
- configs[2].cf_name = "Simul_efun file";
- configs[2].cf_type = CF_STR;
- configs[2].u.cf_str = "/obj/simul_efun";
-
- configs[3].cf_name = "Preload file";
- configs[3].cf_type = CF_STR;
- configs[3].u.cf_str = "room/init_file";
-
- configs[4].cf_name = "Swap file";
- configs[4].cf_type = CF_STR;
- configs[4].u.cf_str = "MacMud_swap_";
-
- configs[5].cf_name = "Forced include file";
- configs[5].cf_type = CF_STR;
- configs[5].u.cf_str = "/include/standard.h";
-
- configs[6].cf_name = "Mudlib directory";
- configs[6].cf_type = CF_STR;
- configs[6].u.cf_str = "";
-
- configs[7].cf_name = "Player directory";
- configs[7].cf_type = CF_STR;
- configs[7].u.cf_str = "players";
-
- configs[8].cf_name = "Domain directory";
- configs[8].cf_type = CF_STR;
- configs[8].u.cf_str = "players";
-
- configs[9].cf_name = "Default castle file";
- configs[9].cf_type = CF_STR;
- configs[9].u.cf_str = "room/def_castle.c";
-
- configs[10].cf_name = "Default workroom file";
- configs[10].cf_type = CF_STR;
- configs[10].u.cf_str = "room/def_workroom.c";
-
- configs[11].cf_name = "Admin log files";
- configs[11].cf_type = CF_STR;
- configs[11].u.cf_str = "";
-
- configs[12].cf_name = "Maximum local log size";
- configs[12].cf_type = CF_INT;
- configs[12].u.cf_int = 50000;
-
- configs[13].cf_name = "Maximum global log size";
- configs[13].cf_type = CF_INT;
- configs[13].u.cf_int = 1000000;
-
- configs[14].cf_name = "Maximum read_file size";
- configs[14].cf_type = CF_INT;
- configs[14].u.cf_int = 50000;
-
- configs[15].cf_name = "Cleanup time";
- configs[15].cf_type = CF_INT;
- configs[15].u.cf_int = 7200;
-
- configs[16].cf_name = "Swap time";
- configs[16].cf_type = CF_INT;
- configs[16].u.cf_int = 900;
-
- configs[17].cf_name = "Reset time";
- configs[17].cf_type = CF_INT;
- configs[17].u.cf_int = 3600;
-
- configs[18].cf_name = "Evaluator stack size";
- configs[18].cf_type = CF_INT;
- configs[18].u.cf_int = 1000;
-
- configs[19].cf_name = "Compiler stack size";
- configs[19].cf_type = CF_INT;
- configs[19].u.cf_int = 200;
-
- configs[20].cf_name = "Maximum bitstring size";
- configs[20].cf_type = CF_INT;
- configs[20].u.cf_int = 1200;
-
- configs[21].cf_name = "Living hash table size";
- configs[21].cf_type = CF_INT;
- configs[21].u.cf_int = 100;
-
- configs[22].cf_name = "Port number";
- configs[22].cf_type = CF_INT;
- configs[22].u.cf_int = 8888;
-
- configs[23].cf_name = "Maximum local variables";
- configs[23].cf_type = CF_INT;
- configs[23].u.cf_int = 20;
-
- configs[24].cf_name = "Maximum evaluation cost";
- configs[24].cf_type = CF_INT;
- configs[24].u.cf_int = 100000;
-
- configs[25].cf_name = "Maximum array size";
- configs[25].cf_type = CF_INT;
- configs[25].u.cf_int = 1000;
-
- configs[26].cf_name = "Maximum players";
- configs[26].cf_type = CF_INT;
- configs[26].u.cf_int = 50;
-
- configs[27].cf_name = "Hash table size";
- configs[27].cf_type = CF_INT;
- configs[27].u.cf_int = 2203;
-
- configs[28].cf_name = "Object hash table size";
- configs[28].cf_type = CF_INT;
- configs[28].u.cf_int = 1009;
-
- configs[29].cf_name = "Maximum transfer bytes";
- configs[29].cf_type = CF_INT;
- configs[29].u.cf_int = 10000;
-
- configs[30].cf_name = "Maximum string length";
- configs[30].cf_type = CF_INT;
- configs[30].u.cf_int = 131072;
-
- configs[31].cf_name = "Reserved memory size";
- configs[31].cf_type = CF_INT;
- configs[31].u.cf_int = 0;
-
- configs[32].cf_name = "Maximum trace depth";
- configs[32].cf_type = CF_INT;
- configs[32].u.cf_int = 20;
-
- configs[33].cf_name = "Debug level";
- configs[33].cf_type = CF_INT;
- configs[33].u.cf_int = 0;
-
- configs[34].cf_name = "Idle level";
- configs[34].cf_type = CF_INT;
- configs[34].u.cf_int = 0;
-
- configs[35].cf_name = "Trace compilations";
- configs[35].cf_type = CF_INT;
- configs[35].u.cf_int = 0;
-
- configs[36].cf_name = "Restart mud automatically";
- configs[36].cf_type = CF_INT;
- configs[36].u.cf_int = 0;
-
- configs[37].cf_name = "Required runtime memory";
- configs[37].cf_type = CF_INT;
- configs[37].u.cf_int = 1024000;
-
- configs[38].cf_name = "Multi user";
- configs[38].cf_type = CF_INT;
- configs[38].u.cf_int = 0;
-
- configs[39].cf_name = "What message ?";
- configs[39].cf_type = CF_STR;
- configs[39].u.cf_int = "What ?\n";
- }
-
- void read_config(void)
- {
- short i;
- long len;
- char *s;
- char *conf;
- Handle confHdl;
-
- set_def_configs();
- confHdl = GetResource('CONF',0);
- if (confHdl) {
- HLock(confHdl);
- conf = (char *)(*confHdl);
- for (i = 0; i < CONFIG_SIZE; i++) {
- if (configs[i].cf_type == CF_STR) {
- len = strlen(conf);
- if ((s = malloc(len+1))) {
- memcpy(s, conf, len);
- s[len] = '\0';
- configs[i].u.cf_str = s;
- }
- conf += len + 1;
- } else if (configs[i].cf_type == CF_INT) {
- configs[i].u.cf_int = *((long *)conf);
- conf += sizeof(long);
- }
- }
- HUnlock(confHdl);
- ReleaseResource(confHdl);
- }
- }
-
- /*
- * Init some global arrays, formerly declared with a predefined
- * value from config.h as their size. They must now be malloc'ed.
- * This is not very beautiful, but the advantage is, that everything
- * is easily, dynamically tuned.
- */
-
- extern int gRuntimeMem;
- extern char **local_names; /* prelang.y */
- extern unsigned short *type_of_locals; /* prelang.y */
- extern struct svalue *start_of_stack; /* interpret.c */
- extern int *comp_stack; /* prelang.y */
- extern struct object **hashed_living; /* object.c */
- extern struct interactive **all_players; /* comm1.c */
- extern struct control_stack *control_stack; /* interpret.c */
- extern long time_to_swap; /* main.c */
- extern int port_number; /* main.c */
- extern int d_flag; /* main.c */
- extern int t_flag; /* main.c */
- extern int comp_flag; /* main.c */
- #ifdef NLHACK
- extern char **log_admin_files; /* nlhack.c */
- extern int nr_log_admin_files;
- #endif
-
- void init_global_configs()
- {
- #ifdef NLHACK
- char *p, n = 0, *start;
- #endif
-
- gRuntimeMem = RUNTIME_MEMORY;
- local_names = (char **) calloc(MAX_LOCAL, sizeof (char *));
- type_of_locals = (unsigned short *)
- calloc(MAX_LOCAL, sizeof (unsigned short));
- start_of_stack = (struct svalue *)
- calloc(EVALUATOR_STACK_SIZE, sizeof (struct svalue));
- comp_stack = (int *) calloc(COMPILER_STACK_SIZE, sizeof (int));
- hashed_living = (struct object **)
- calloc(LIVING_HASH_SIZE, sizeof (struct object *));
- all_players = (struct interactive **)
- calloc(MAX_PLAYERS, sizeof (struct interactive *));
- control_stack = (struct control_stack *)
- calloc(MAX_TRACE, sizeof(struct control_stack));
- time_to_swap = (long) TIME_TO_SWAP;
- port_number = PORTNO;
- #ifdef NLHACK
- n = 0;
- if (LOG_ADMIN_FILES && strlen(LOG_ADMIN_FILES)) {
- p = LOG_ADMIN_FILES;
- do {
- n++;
- } while (p = strchr(p + 1, ','));
- log_admin_files = (char **) malloc(n * sizeof (char *));
- start = LOG_ADMIN_FILES;
- n = 0;
- do {
- log_admin_files[n++] = start;
- if (!(p = strchr(start, ',')))
- break;
- *p = '\0';
- start = p + 1;
- } while (*start);
- }
- nr_log_admin_files = n;
- #endif
- }
-